/******************************************************************************
 *
 * MotionViewer
 * Copyright (C) 2007 Sangyoon Lee, Electronic Visualization Laboratory, 
 * University of Illinois at Chicago
 *
 * This software is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either Version 2.1 of the License, or 
 * (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
 * License for more details.
 * 
 * You should have received a copy of the GNU Lesser Public License along
 * with this software; if not, write to the Free Software Foundation, Inc., 
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * Questions or comments about MotionViewer should be directed to 
 * cavern@evl.uic.edu
 *
 *****************************************************************************/


#ifndef __VICONCHARACTER_H__
#define __VICONCHARACTER_H__

#include <ogre.h>
using namespace Ogre;

class ViconMotionDataSet;

class ViconCharacter
{
public:
	
	ViconCharacter(SceneManager* mgr, SceneNode* head);
	~ViconCharacter();
	
	bool createCharacter(const char* filename);
	void connectToMotionData(ViconMotionDataSet* dataset);
	void disconnectMotionData();
	void loadSkeletonMapping(const char* mapfile);

	void update(float addedTime);
	void setPosition(float x, float y, float z);
	void getPosition(float* pos);

	void setDataSet(ViconMotionDataSet* dataset) { m_pDataSet = dataset;}
	ViconMotionDataSet* getDataSet() { return m_pDataSet;}

	std::string getName() { return m_sName;}
	std::string getMapFileName() { return m_sMapFileName;}
	unsigned int getNumBones();
	

	int			getID() { return m_iID;}

	//added by Kaushal for Project 3
	Entity * getEntity(void) { return m_pEntity; }

protected:
	
	void updateSkeleton();

	int					m_iID;
	std::string			m_sName;
	std::string			m_sMapFileName;

	ViconMotionDataSet* m_pDataSet;
	SceneManager*		m_pSceneMgr;
	SceneNode*			m_pHeadNode;
	Entity*				m_pEntity;
	SceneNode*			m_pBaseNode;
	SkeletonInstance*	m_pSkeleton;
	AnimationState*     m_pAnimState;

	// skeleton mapping
	std::vector<int>	m_vBoneMap; // Vicon Body(rank) to Ogre Bone(int)

	// binding pose: initial local Quaternion (Ogre)
	std::vector<Quaternion>		m_vBindingPose;



};

#endif